package cn.gzmli.dtt.common.utils;

import cn.gzmli.dtt.common.entity.PageInfo;
import cn.gzmli.dtt.common.entity.vo.UserOrgAuthObjVO;
import cn.gzmli.dtt.sbzyc.exception.SystemException;
import cn.gzmli.dtt.sbzyc.util.fileupload.UploadFileEnum;
import com.alibaba.druid.sql.PagerUtils;
import com.alibaba.druid.util.JdbcConstants;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xiaoleilu.hutool.date.DateUtil;
import com.xiaoleilu.hutool.util.StrUtil;

import javax.persistence.Column;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Pattern;

/**
 * 字符串处理工具类
 *
 * @author wonderful
 * @create 20151110
 */
public class BaseUtil {

    /**
     * 逗号分隔的条件字符串转换为符号sql in条件标准的字符串
     *
     * @param doStrs
     * @return
     * @throws Exception
     */
    public static String toInCond(String doStrs) {
        if (doStrs != null && !doStrs.equals("")) {
            if (doStrs.contains(",")) {
                doStrs = "\\'" + doStrs.replaceAll(",", "\\\\',\\\\'") + "\\'";
            } else {
                doStrs = "\\'" + doStrs + "\\'";
            }
        } else if (doStrs != null && doStrs.equals("")) {
            doStrs = null;
        }
        return doStrs;
    }

    public static String toInCondNotSprit(String doStrs) {
        if (doStrs != null && !doStrs.equals("")) {
            if (doStrs.contains(",")) {
                doStrs = "'" + doStrs.replaceAll(",", "','") + "'";
            } else {
                doStrs = "'" + doStrs + "'";
            }
        } else {
            doStrs = "NULL";
        }
        return doStrs;
    }

    /**
     * @param list
     * @return String
     * @throws Exception
     * @Title: convertListToString
     * @Description: 将list集合中数据转换为用逗号分隔的字符串
     */
    public static String convertListToString(List<?> list) throws Exception {
        if (list != null && list.size() > 0) {
            StringBuilder ids = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                ids.append(list.get(i)).append(",");
            }
            return ids.substring(0, ids.length() - 1);
        } else {
            return "";
        }
    }

    /**
     * @param list
     * @return String
     * @throws Exception
     * @Title: convertListToSQLString
     * @Description: 将list集合中字符串转换为SQL语句中用逗号分隔的标准语句
     */
    public static String convertListToSQLString(List<String> list) throws Exception {
        if (list != null && list.size() > 0) {
            StringBuilder ids = new StringBuilder();
            for (int i = 0; i < list.size(); i++) {
                ids.append("'").append(list.get(i)).append("'").append(",");
            }
            return ids.substring(0, ids.length() - 1);
        } else {
            return "";
        }
    }

    /**
     * @param str
     * @return List
     * @throws Exception
     * @Title: convertStringToList
     * @Description: 将按逗号分隔的字符串转换为list集合
     */
    public static List<String> convertStringToList(String str) throws Exception {
        if (str == null || str.trim().length() == 0 || !str.contains(",")) {
            return new ArrayList<String>();
        } else {
            return Arrays.asList(str.split(","));
        }
    }

    /**
     * @param str      按某种分隔符连接的字符串
     * @param included 被包含的字符串
     * @param pattern  分隔规则
     * @return boolean
     * @throws Exception
     * @Title: isInclude
     * @Description: 是否存在被包含的字符串
     */
    public static boolean isInclude(String str, String included, String pattern) {
        if (str == null || str.trim().length() == 0 || pattern == null) {
            return false;
        } else {
            if (str.contains(pattern)) {
                String[] stringArray = str.split(pattern);
                for (int i = 0; i < stringArray.length; i++) {
                    if (stringArray[i].equals(included)) {
                        return true;
                    }
                }
                return false;
            } else {
                if (str.equals(included)) {
                    return true;
                } else {
                    return false;
                }
            }
        }
    }

    /**
     * 验证请求的参数是否为空或空字符串
     *
     * @throws Exception
     */
    public static boolean isNotEmpty(Object object) throws Exception {

        boolean isTrue = false;

        if (object != null && (object.getClass().equals(Integer.class) || object.getClass().equals(Long.class))) {

            isTrue = true;

        } else if (object != null && object.getClass().equals(String.class)) {
            if (!object.toString().equals("")) {
                isTrue = true;
            }

        }

        return isTrue;
    }

    public static String replaceFirst(String content, String regex, String replacement) {
        return Pattern.compile(regex).matcher(content).replaceFirst(replacement);
    }

    public static StringBuilder getCommomID(String prefix, Integer id) throws Exception {
        StringBuilder idBuilder = new StringBuilder();
        idBuilder.append(id + 1);
        if (idBuilder.length() == 1) {
            idBuilder.insert(0, "000");
        } else if (idBuilder.length() == 2) {
            idBuilder.insert(0, "00");
        } else {
            idBuilder.insert(0, "0");
        }
        idBuilder.insert(0, prefix);
        return idBuilder;
    }

    // 获取占位符
    public static String getPlaceholder(String str) throws Exception {
        if (str.contains("，")) {
            str = str.replaceAll("，", ",");
        }
        return str.replaceAll("[\\d\\w]+", "?");
    }

    public static String getPlaceholder(int size) throws Exception {
        StringBuilder placeholder = new StringBuilder();
        for (int i = 0; i < size; i++) {
            placeholder.append("?,");
        }
        return placeholder.substring(0, placeholder.length() > 0 ? placeholder.length() - 1 : 0);
    }

    public static int getPlaceholderSize(String str) throws Exception {
        if (str.contains("，")) {
            str = str.replaceAll("，", ",");
        }
        return str.split(",").length;
    }

    public static <T> List<T> getArgs(String str, Class<T> cla) throws Exception {
        if (str.contains("，")) {
            str = str.replaceAll("，", ",");
        }
        return Arrays.asList((T[]) str.split(","));
    }

    public static <T> List<T> getArgsWithPattern(String str, String pattern, Class<T> cla) throws Exception {
        return Arrays.asList((T[]) str.replaceAll(pattern, "").split(","));
    }

    public static void fillSqlAndArgs(StringBuilder sql, Map<String, Object> condition, List<Object> args) throws Exception {
        fillSqlAndArgs(sql, condition, args, null, null);
    }

    public static void fillSqlAndArgs(StringBuilder sql, Map<String, Object> condition, List<Object> args, PageInfo pageInfo, BaseDao baseDao) throws Exception {
        fillSqlAndArgs(sql, condition, args, pageInfo, baseDao, null);
    }

    public static void fillSqlAndArgs(StringBuilder sql, Map<String, Object> condition, List<Object> args, PageInfo pageInfo, BaseDao baseDao, Map<String, String> orderMap) throws Exception {
        for (Map.Entry<String, Object> entry : condition.entrySet()) {
            sql.append(entry.getKey());
            if (entry.getValue() instanceof List) {
                args.addAll((List) entry.getValue());
            } else {
                args.add(entry.getValue());
            }
        }
        if (orderMap != null && orderMap.size() > 0) {
            sql.append(" ORDER BY ");
            for (Map.Entry<String, String> entry : orderMap.entrySet()) {
                sql.append(entry.getKey()).append(" ").append(entry.getValue()).append(",");
            }
            sql.deleteCharAt(sql.length() - 1);
        }
        queryTotalCount(sql, args, pageInfo, baseDao);
    }

    public static StringBuffer fillChildCondion(Map<String, Object> condition, List<Object> args) {
        StringBuffer conditionBuf = new StringBuffer();
        for (Map.Entry<String, Object> entry : condition.entrySet()) {
            conditionBuf.append(entry.getKey());
            if (entry.getValue() instanceof List) {
                args.addAll((List) entry.getValue());
            } else {
                args.add(entry.getValue());
            }
        }
        return conditionBuf;
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, BaseDao baseDao) throws Exception {
        List<Object> args = new ArrayList<>();
        fillSqlAndArgs(sql, condition, args);
        if (args.size() > 0) {
            return baseDao.getJdbcTemplate().queryForList(sql.toString(), args.toArray());
        } else {
            return baseDao.getJdbcTemplate().queryForList(sql.toString());
        }
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, PageInfo pageInfo, BaseDao baseDao) throws Exception {
        List<Object> args = new ArrayList<>();
        fillSqlAndArgs(sql, condition, args);
//		String countSql=sql.toString().replace("SELECT * FROM","SELECT COUNT(*) totalRows FROM");
        if (pageInfo.getOrderData()!=null && pageInfo.getOrderData().length()>0){
            sql.append(" ORDER BY ").append(pageInfo.getOrderData());
        }
        queryTotalCount(sql, args, pageInfo, baseDao);
        if (args.size() > 0) {
            return baseDao.getJdbcTemplate().queryForList(sql.toString(), args.toArray());
        } else {
            return baseDao.getJdbcTemplate().queryForList(sql.toString());
        }
    }

    public static void queryTotalCount(StringBuilder sql, List<Object> args, PageInfo pageInfo, BaseDao baseDao) throws Exception {
        if (pageInfo != null && pageInfo.getPageSize() > 0) {
            // 采用阿里的分页总数查询sql
            String countSql = PagerUtils.count(sql.toString(), JdbcConstants.MYSQL);
            int count;
            if (args.size() > 0) {
                count = baseDao.getJdbcTemplate().queryForObject(countSql, Integer.class, args.toArray());
            } else {
                count = baseDao.getJdbcTemplate().queryForObject(countSql, Integer.class);
            }
            pageInfo.setTotalRows(count);
            pageInfo.createTotalPages();
            sql.append(" Limit " + ((pageInfo.getCurPage() - 1) * pageInfo.getPageSize()) + "," + pageInfo.getPageSize());
        }
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, PageInfo pageInfo, BaseDao baseDao, Object... args) throws Exception {
        queryTotalCount(sql, Arrays.asList(args), pageInfo, baseDao);
        if (args.length > 0) {
            return baseDao.getJdbcTemplate().queryForList(sql.toString(), args);
        } else {
            return baseDao.getJdbcTemplate().queryForList(sql.toString());
        }
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, PageInfo pageInfo, BaseDao baseDao, String orderName, boolean isASC) throws Exception {
        return getData(sql, condition, pageInfo, baseDao, null, orderName, isASC);
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, PageInfo pageInfo, BaseDao baseDao, String groupbyName, String orderName, boolean isASC) throws Exception {
        List<Object> args = new ArrayList<>();
        fillSqlAndArgs(sql, condition, args);
        if (StrUtil.isNotBlank(groupbyName)) {
            sql.append(" GROUP BY ").append(groupbyName);
        }
        if (pageInfo != null && BaseUtil.isNotEmpty(pageInfo.getOrderData())) {
            sql.append(" ORDER BY ").append("" + pageInfo.getOrderData());
        } else if (isASC) {
            sql.append(" ORDER BY ").append(orderName).append(" ASC");
        } else {
            sql.append(" ORDER BY ").append(orderName).append(" DESC");
        }
        queryTotalCount(sql, args, pageInfo, baseDao);
        if (args.size() > 0) {
            return baseDao.getJdbcTemplate().queryForList(sql.toString(), args.toArray());
        } else {
            return baseDao.getJdbcTemplate().queryForList(sql.toString());
        }
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, BaseDao baseDao, String orderName, boolean isASC) throws Exception {
        return getData(sql, condition, null, baseDao, orderName, isASC);
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, BaseDao baseDao, String groupbyName, String orderName, boolean isASC) throws Exception {
        return getData(sql, condition, null, baseDao, groupbyName, orderName, isASC);
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, PageInfo pageInfo, BaseDao baseDao, Map<String, String> orderMap) throws Exception {
        String query;
        List<Object> args = new ArrayList<>();
        fillSqlAndArgs(sql, condition, args);
        if (pageInfo != null && pageInfo.getCurPage() > 0) {
            queryTotalCount(sql, args, pageInfo, baseDao);
        }
        if (orderMap != null && orderMap.size() > 0) {
            sql.append(" ORDER BY ");
            for (Map.Entry<String, String> entry : orderMap.entrySet()) {
                sql.append(entry.getKey()).append(" ").append(entry.getValue()).append(",");
            }
            query = sql.substring(0, sql.length() - 1);
        } else {
            query = sql.toString();
        }
        if (args.size() > 0) {
            return baseDao.getJdbcTemplate().queryForList(query, args.toArray());
        } else {
            return baseDao.getJdbcTemplate().queryForList(query);
        }
    }

    public static List<Map<String, Object>> getData(StringBuilder sql, Map<String, Object> condition, BaseDao baseDao, Map<String, String> orderMap) throws Exception {
        return getData(sql, condition, null, baseDao, orderMap);
    }

    public static List<Map<String, Object>> getPageData(StringBuffer sql, BaseDao baseDao, PageInfo pageInfo, List<Object> args){
        List<Map<String, Object>> result =new ArrayList<>();
        if (pageInfo != null && pageInfo.getCurPage() > 0) {
            sql.append("LIMIT " + pageInfo.getStartRow() + "," + pageInfo.getPageSize());
            result= baseDao.getJdbcTemplate().queryForList(sql.toString(), args.toArray());
            String countSql = "SELECT FOUND_ROWS() FROM DUAL";
            pageInfo.setTotalRows(baseDao.getJdbcTemplate().queryForObject(countSql, Integer.class));
            pageInfo.createTotalPages();
        }else{
            result= baseDao.getJdbcTemplate().queryForList(sql.toString(), args.toArray());
        }
        return result;
    }

    /**
     * 获取文件上传路径
     *
     * @param root 项目根路径
     * @param type 文件类型
     * @return 返回文件路径
     * @throws Exception
     */
    public static String getFilePath(String root, String type) throws SystemException {
        try {
            StringBuilder path = new StringBuilder(root);
            path.append("upload").append(File.separator);
            Map<Integer, UploadFileEnum> map = UploadFileEnum.fileMap();
            Integer fileType = Integer.valueOf(type);
            path.append(map.get(fileType).getPathName());
            System.out.print("BaseUtil getFilePath=" + path.toString());
            return path.toString();
        } catch (NumberFormatException e) {
            throw new SystemException("projectDocType参数错误,只能为 1-16 的数字");
        }
    }

    // 数据过滤
    public static List<Map<String, Object>> dataFilter(List<Map<String, Object>> dataList) {
        if (dataList.size() > 0 && dataList.get(0).get("tID") != null) {
            Map<Object, Map<String, Object>> filter = new LinkedHashMap<>();
            for (Map<String, Object> data : dataList) {
                Map<String, Object> map = filter.get(data.get("bID"));
                if (map == null || data.get("tID") == null || (Integer) map.get("tID") < (Integer) data.get("tID")) {
                    filter.put(data.get("bID"), data);
                }
            }
            dataList = new ArrayList<>();
            dataList.addAll(filter.values());
        }
        return dataList;
    }


    /**
     * Title:add
     * Description: 金额数据加法
     * return:BigDecimal
     * tags:@param v1
     * tags:@param v2
     * tags:@return
     *
     * @author:superKing_zhanglh
     * @date 2018年2月8日
     */
    public static Double add(Double v1, Double v2) {
        java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
        nf.setGroupingUsed(false);
        BigDecimal b1 = new BigDecimal(nf.format(v1));
        BigDecimal b2 = new BigDecimal(nf.format(v2));
        return b1.add(b2).setScale(3, BigDecimal.ROUND_UP).doubleValue();
    }

    /**
     * Title:sub
     * Description:金额数据减法
     * return:BigDecimal
     * tags:@param v1
     * tags:@param v2
     * tags:@return
     *
     * @author:superKing_zhanglh
     * @date 2018年2月8日
     */
    public static Double sub(Double v1, Double v2) {
        java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
        nf.setGroupingUsed(false);
        BigDecimal b1 = new BigDecimal(nf.format(v1));
        BigDecimal b2 = new BigDecimal(nf.format(v2));
        return b1.subtract(b2).setScale(3, BigDecimal.ROUND_UP).doubleValue();
    }

    /**
     * 获取本周起始时间
     *
     * @return 返回yyyy-MM-dd HH:mm:ss
     */
    public static String getBeginOfWeek() {
        return DateUtil.formatDateTime(DateUtil.beginOfWeek(new Date()));
    }

    /**
     * 获取本周结束时间
     *
     * @return 返回yyyy-MM-dd HH:mm:ss
     */
    public static String getEndOfWeek() {
        Calendar calendar = DateUtil.endOfWeek(Calendar.getInstance(), false);
        calendar.add(Calendar.DAY_OF_MONTH, 1);
        return DateUtil.formatDateTime(calendar.getTime());
    }

    /**
     * 获取本月起始时间
     *
     * @return 返回yyyy-MM-dd HH:mm:ss
     */
    public static String getBeginOfMonth() {
        return DateUtil.formatDateTime(DateUtil.beginOfMonth(new Date()));
    }

    /**
     * 获取本月结束时间
     *
     * @return 返回yyyy-MM-dd HH:mm:ss
     */
    public static String getEndOfMonth() {
        return DateUtil.formatDateTime(DateUtil.endOfMonth(new Date()));
    }


    public static void main(String[] args) {
        /*java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
        nf.setGroupingUsed(false);
        Double f = BaseUtil.add(900000000.89d, 50.22d);
        System.out.println(f + ";" + nf.format(f));*/
        double n = sub(5.333,2.111);
        System.out.println(n);

    }

    /**
     * 过滤replaceAll or replace替换方法可能会出现异常的关键字
     * wonderful
     *
     * @return
     */
    public static String filterReplacementKeywords(String value) {

        String result = "";
        if (value.indexOf('$', 0) > -1) {
            while (value.length() > 0) {
                if (value.indexOf('$', 0) > -1) {
                    result += value.subSequence(0, value.indexOf('$', 0));
                    result += "\\$";
                    value = value.substring(value.indexOf('$', 0) + 1, value.length());
                } else {
                    result += value;
                    value = "";
                }
            }

        } else {
            result = value;
        }
        return result;
    }

    /**
     * 根据逗号分隔的in条件字符串以及以in结尾的sql语句，在sql上补充jdbcTemplate参数占位符及sql括弧，并返回支持jdbcTemplate的预编译参数数组。
     *
     * @param sql
     * @param argsStr
     * @return Object[] args
     * @throws Exception
     * @author wonderful 20180710
     */
    public static List<Object> toInConds(StringBuffer sql, String argsStr) throws Exception {
        List<Object> argsList = null;
        if (argsStr != null && !argsStr.equals("") && argsStr.indexOf(",") != -1) {
            Object[] args = argsStr.split(",");
            argsList = new ArrayList<Object>();
            StringBuffer placeHolders = new StringBuffer();
            for (Object arg : args) {
                placeHolders.append("?,");
                argsList.add(arg);
            }
            sql.append(" (" + placeHolders.substring(0, placeHolders.length() - 1) + ") ");
        } else if (argsStr != null && !argsStr.equals("")) {
            argsList = new ArrayList<Object>();
            Object arg = argsStr;
            argsList.add(arg);
            sql.append(" (?) ");
        }
        return argsList;
    }


    /**
     * 将spring jdbcTemplate queryForList查询的map结果集 反射生成对应的bean
     * @autor superKing_zhanglh
     * @param clazz         意向反射的实体.clazz
     * @param jdbcMapResult 查询结果集  key is UpperCase
     * @return
     * @see
     */
    public static <T> T reflect(Class<T> clazz, Map<String, Object> jdbcMapResult)
    {
        // 获得
        Field[] fields = clazz.getDeclaredFields();

        // 存放field和column对应关系，该关系来自于VO对象的 @Column配置
        Map<String/* field name in modelBean */, String/* column in db */> fieldHasColumnAnnoMap = new LinkedHashMap<String, String>();
        Annotation[] annotations = null;
        for (Field field : fields)
        {
            annotations = field.getAnnotations();
            for (Annotation an : annotations)
            {
                if (an instanceof Column)
                {
                    Column column = (Column) an;
                    fieldHasColumnAnnoMap.put(field.getName(), column.name());
                }
            }
        }

        // 存放field name 和 对应的来自map的该field的属性值，用于后续reflect成ModelBean
        Map<String, Object> conCurrent = new LinkedHashMap<String, Object>();

        for (Map.Entry<String, String> en : fieldHasColumnAnnoMap.entrySet())

        {
            // 将column大写。因为jdbcMapResult key is UpperCase
            String key = en.getValue().toUpperCase();
            // 获得map的该field的属性值
            Object value = jdbcMapResult.get(key);
            // 确保value有效性，防止JSON reflect时异常
            if (value != null)
            {
                conCurrent.put(en.getKey(), jdbcMapResult.get(key));
            }

        }

        // fastjson reflect to modelbean
        return JSON.parseObject(JSON.toJSONString(conCurrent), clazz);

    }


    public static <T> T convertMapToBean(Class<T> clazz, Map<String,Object> map) {
        T obj = null;
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
            obj = clazz.newInstance(); // 创建 JavaBean 对象
            // 给 JavaBean 对象的属性赋值
            PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
            for (int i = 0; i < propertyDescriptors.length; i++) {
                PropertyDescriptor descriptor = propertyDescriptors[i];
                String propertyName = descriptor.getName();
                if (map.containsKey(propertyName)) {
                    // 下面一句可以 try 起来，这样当一个属性赋值失败的时候就不会影响其他属性赋值。
                    Object value = map.get(propertyName);
                    if ("".equals(value)) {
                        value = null;
                    }
                    Object[] args = new Object[1];
                    args[0] = value;
                    descriptor.getWriteMethod().invoke(obj, args);

                }
            }
        } catch (IllegalAccessException e) {
            System.out.println(e.getMessage());
        } catch (IntrospectionException e) {
            System.out.println(e.getMessage());
        } catch (IllegalArgumentException e) {
            System.out.println(e.getMessage());
        } catch (InstantiationException e) {
            System.out.println(e.getMessage());
        }catch (InvocationTargetException e){
            System.out.println(e.getMessage());
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
        return (T) obj;
    }

    /**
     * 用户权限域业务数据转换
     * @author Pyj
     * @date 2019-08-20
     * @param object
     * @return
     * @throws Exception
     */
    public static Map<String, Object> getRRSIDs(Object object) throws Exception {
        Map<String, Object> map = new HashMap();
        Gson gson = new Gson();
        StringBuilder regionIds = new StringBuilder();
        StringBuilder routeIds = new StringBuilder();
        StringBuilder sectionIds = new StringBuilder();
        StringBuilder siteIds = new StringBuilder();

        // Gson解析List
        Type type = new TypeToken<ArrayList<UserOrgAuthObjVO>>(){}.getType();
        List<UserOrgAuthObjVO> userAuthObjList = (List<UserOrgAuthObjVO>)gson.fromJson(object.toString(), type);

        for (UserOrgAuthObjVO userOrgAuthObj:userAuthObjList) {
            regionIds.append(userOrgAuthObj.getRegionId()).append(",");
            routeIds.append(userOrgAuthObj.getRouteId()).append(",");
            sectionIds.append(userOrgAuthObj.getSectionId()).append(",");
            siteIds.append(userOrgAuthObj.getId()).append(",");
        }
        if (isNotEmpty(regionIds.toString())) {
            map.put("regionIds", regionIds.deleteCharAt(regionIds.length() - 1).toString());
        }
        if (isNotEmpty(routeIds.toString())) {
            map.put("routeIds", routeIds.deleteCharAt(routeIds.length() - 1).toString());
        }
        if (isNotEmpty(sectionIds.toString())) {
            map.put("sectionIds", sectionIds.deleteCharAt(sectionIds.length() - 1).toString());
        }
        if (isNotEmpty(siteIds.toString())) {
            map.put("siteIds", siteIds.deleteCharAt(siteIds.length() - 1).toString());
        }
        map.put("userAuthObjList", userAuthObjList);
        return map;
    }

}
